function tabbarinit() {
  return [
          {
            "current": 0,
            "pagePath": "/pages/index/index",
            "iconPath": "/image/12.png",
            "selectedIconPath": "/image/11.png",
            "text": "主页"
          },
          {
            "current": 0,
            "pagePath": "/pages/home/home",
            "iconPath": "/image/cart2.png",
            "selectedIconPath": "/image/cart.png",
            "text": "选购"
          },
          {
            "current": 0,
            "pagePath": "/pages/casedesign/casedesign",
            "iconPath": "/image/22.png",
            "selectedIconPath": "/image/21.png",
            "text": "团购方案"
          },
          {
            "current": 0,
            "pagePath": "/pages/experience/experience",
            "iconPath": "/image/32.png",
            "selectedIconPath": "/image/31.png",
            "text": "家居课堂"
          },
          {
            "current": 0,
            "pagePath": "/pages/my/my",
            "iconPath": "/image/42.png",
            "selectedIconPath": "/image/41.png",
            "text": "我的"
          }
    // {
    //   "current": 0,
    //   "pagePath": "/pages/index/index",
    //   "text":"首页",
    //   "iconPath":"/image/cart2.png",
    //   "selectedIconPath":"/image/cart2.png"
    // },
    // {
    //   "current": 0,
    //   "pagePath": "/pages/museum/museum",
    //   "text":"博物馆",
    //   "iconPath":"/img/tab_museums.png",
    //   "selectedIconPath":"/img/tab_museum.png"
    // },
    // {
    //   "current": 0,
    //   "pagePath":"/pages/mission/mission",
    //   "text":"小任务",
    //   "iconPath":"/img/tab_missions.png",
    //   "selectedIconPath":"/img/tab_mission.png"
 
    // },
    // {
    //   "current": 0,
    //   "pagePath":"/pages/resources/resources",
    //   "text":"好资源",
    //   "iconPath":"/img/tab_resources.png",
    //   "selectedIconPath":"/img/tab_resource.png"
    // },
    // {
    //   "current": 0,
    //   "pagePath":"/pages/mine/mines",
    //   "text":"我的",
    //   "iconPath":"/img/tab_mines.png",
    //   "selectedIconPath":"/img/tab_mine.png"
    // }
  ]
 
}
//tabbar 主入口
function tabbarmain(bindName = "tabdata", id, target) {
  console.log(id,'if')
  var that = target;
  var bindData = {};
  var otabbar = tabbarinit();
  otabbar[id]['iconPath'] = otabbar[id]['selectedIconPath']//换当前的icon
  otabbar[id]['current'] = 1;
  that.setData({
    canIUseGetUserProfile: false
  })

  if (wx.getUserProfile) {
    that.setData({
      canIUseGetUserProfile: true
    })
  }
  bindData[bindName] = otabbar
  that.setData({ bindData });
}

function getUserInfo(e) {
  // 不推荐使用getUserInfo获取用户信息，预计自2021年4月13日起，getUserInfo将不再弹出弹窗，并直接返回匿名的用户个人信息
  this.setData({
    userInfo: e.detail.userInfo,
    hasUserInfo: true,
     header:res.userInfo.avatarUrl,
     nickName:res.userInfo.nickName
  })
}

function getUserProfile(e) {
  // 推荐使用wx.getUserProfile获取用户信息，开发者每次通过该接口获取用户个人信息均需用户确认
  // 开发者妥善保管用户快速填写的头像昵称，避免重复弹窗
  wx.getUserProfile({
    desc: '用于完善会员资料', // 声明获取用户个人信息后的用途，后续会展示在弹窗中，请谨慎填写
    success: (res) => {
      this.setData({
        userInfo: res.userInfo,
        hasUserInfo: true,
        header:res.userInfo.avatarUrl,
         nickName:res.userInfo.nickName
      })

      wx.switchTab({
        url: '/pages/my/my',
      })
    }
  })
}

 
module.exports = {
  tabbar: tabbarmain
}